package cn.com.bdqn.controller;

import cn.com.bdqn.entity.BasDict;
import cn.com.bdqn.service.BasDictService;
import cn.com.bdqn.utils.ReturnData;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/basDict")
@Api(tags = "数据字典管理接口")
public class BasDictController {

    @Autowired
    private BasDictService basDictService;

    @Operation(summary = "根据数据字典类别查询数据")
    @PostMapping("/queryByType")
    public ReturnData queryByType(String dictType){
        try {
            List<BasDict> basDicts = basDictService.queryByType(dictType);
            return ReturnData.ok().put("basDicts",basDicts);
        }catch (Exception e){
            return ReturnData.currError("数据字典异常");
        }
    }
}
